package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import com.itheima.reggie.entity.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper//Mapper出于springboot，不加这个boot不知道你要创建代理对象，因为接口是不能创建对象的
public interface CategoryMapper {
    @Insert("insert into category values (#{id},#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    public int save(Category category);

    @Select("select * from category ORDER BY create_time ASC")
    @Results({@Result(property = "createTime", column = "create_time"),
              @Result(property = "updateTime", column = "update_time"),
              @Result(property = "createUser", column = "create_user"),
              @Result(property = "updateUser", column = "update_user")})
    public List<Category> getPageInfo();

    @Delete("delete from category where id = #{id}")
    public int removeById(Long id);

    @Update("update category set name = #{name},sort = #{sort} where id = #{id}")
    public int updateById(Category category);

    @Select("select * from category WHERE type = #{type} ORDER BY sort ASC,update_time DESC")
    public List<Category> getCategoryName(Category category);

}
